<template>
  <div>
    <div class="background">
      <img src="../assets/shi.jpg" width="100%" height="100%" alt="" />
    </div>
    <div class="front">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <i class="el-icon-loading" />
          <b class="Logo">天 使 物 流</b>
        </div>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="用户名" prop="Account">
            <el-input v-model="ruleForm.Account"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="PassWord">
            <el-input type="password" v-model="ruleForm.PassWord"></el-input>
          </el-form-item>
          <el-form-item>
            <el-row :gutter="1">
              <el-col :span="10"
                ><div class="grid-content bg-purple">
                  <el-button type="success" @click="submitForm('ruleForm')"
                    >立即登录</el-button
                  >
                </div></el-col
              >
              <el-col :span="5"
                ><div class="grid-content bg-purple">
                  <el-button type="info" @click="ddd = true"
                    >无法登陆</el-button
                  >
                </div></el-col
              >
            </el-row>
          </el-form-item>
        </el-form>
        <span v-show="ddd" style="color: white">tip:请联系管理员处理</span>
      </el-card>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ddd: false,
      ruleForm: {
        Account: "",
        PassWord: "",
      },
      rules: {
        Account: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        PassWord: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
  created() {},
  computed: {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$axios
            .post(
              "https://localhost:44399/api/app/deng-lu/deng-lu",
              this.ruleForm
            )
            .then((res) => {
              if (res.data.Data != null) {
                //传递token
                //       // localStorage.setItem("token",res.headers.token)
                //传递用户编号
                sessionStorage.setItem("Id", res.data.Data.Id);
                //传递用户名
                sessionStorage.setItem("Account", res.data.Data.Account);
                this.$message.success("登陆成功");
                this.$router.push("/ManagementBackgroundHomePage");
              } else {
                this.$message.error("用户名或密码错误");
              }
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style scoped>
.background {
  width: 100%;
  height: 100%; /**宽高100%是为了图片铺满屏幕 */
  z-index: -1;
  position: absolute;
}
.front {
  width: 100%;
  height: 100%; /**宽高100%是为了图片铺满屏幕 */
  z-index: 1;
  position: absolute;
}
.clearfix {
  text-align: center;
  font-family: 酷黑;
  font-size: 35px;
  color: rgba(50, 50, 50, 0.8);
}
.el-icon-s-data {
  margin-left: 10px;
  line-height: 55px;
  font-size: 30px;
}
.box-card {
  margin-left: calc(calc(100vw - 400px) / 2);
  width: 400px;
  background-color: rgba(200, 200, 200, 0.6);
  border-color: rgba(200, 200, 200, 0.5);
  border-radius: 10px;
  margin-top: 15%;
  border-radius: 20px;
}
.el-button {
  width: 95px;
}
.el-card__header {
  padding: 10px 15px;
}
</style>
<style>
.el-card__header {
  padding: 5px;
}
body {
  margin: 0;
  padding: 0;
}
</style>